<template>
  <view>
    <u-gap height="20px"></u-gap>

    <view class="dm-box tn-flex tn-flex-row-center tn-flex-col-center" style="height: 150px;">
      <view class="tn-text-xl tn-text-bold " >可提现金额(元)：<text class="money">{{ totalAmount }}</text></view>
    </view>

    <view class="tn-margin">
      <view class="tn-text-bold tn-margin-bottom-xs">提现金额</view>
      <view class="tn-bg-white tn-padding tn-flex tn-flex-row-between tn-flex-col-center">
        <tn-input placeholder="请输入你要提现的金额" type="number" v-model="withdrawAmount" />
        <text class="money" @click="setWithdrawAmount">全部金额</text>
      </view>
    </view>

    <view class="tn-flex tn-flex-row-center" >
      <tn-button background-color="#11AE14" fontColor="#fff" shape="round"  size="lg" @click="withdraw">立即提现到微信</tn-button>
    </view>

    <u-gap height="60px"></u-gap>
    <view class="tn-margin">
      <view class="tn-text-bold">提现说明</view>
      <view class="tn-padding tn-text-sm">
        <view>1.可提现金额为税前金额，实际到账会扣除掉<text class="dm-main-text-color">6%</text>的提现税费。</view>
        <view>2.提现后72小时之内到账，如若超过请联系客服查询。</view>
      </view>
    </view>
    <banner-ad :config="adConfig.wx_banner_player"/>

  </view>
</template>

<script>
import common_mixin from '@/libs/mixin/common_mixin.js'
import UGap from "../../uni_modules/uview-ui/components/u-gap/u-gap.vue";
import BannerAd from "@/components/banner-ad/banner-ad.vue";
import {toast} from "../../utils/utils";

export default {
  components: {BannerAd, UGap},
  mixins: [common_mixin],
  name: "withdraw",
  data() {
    return {
      totalAmount:"0.00",
      withdrawAmount:""
    }
  },
  onShow(){
    this.totalAmount = this.vuex_user.invite_commission ||0
  },
  methods:{
    setWithdrawAmount() {
      if (!this.totalAmount) {
        toast("暂无可提现金额")
        return;
      }
      this.withdrawAmount = this.totalAmount;
    },
    async withdraw() {
      // if (!this.totalAmount) {
      //   toast("暂无可提现金额")
      //   return;
      // }
      // if (!this.withdrawAmount) {
      //   toast("请输入要提现金额")
      //   return;
      // }
      // if (this.withdrawAmount>this.totalAmount) {
      //   this.withdrawAmount=this.totalAmount;
      //   toast("你暂无那么多的提现金额")
      //   return;
      // }
      const that = this;
      let res = await this.$api.withdraw({amount:this.withdrawAmount})
      toast("成功提交提现申请，请耐心等待审核")
      setTimeout(()=>{
        that.tn('/pages_sub/withdraw/withdraw_detail')
      },2000);
    }
  }
}
</script>

<style scoped lang="scss">

</style>
